#delimit; 
global labvar " LW "W\~_{t-1}\~" 
LW2 "W\~^2_{t-1}\~"  
LW3 "W\~^3_{t-1}\~"
LSreal  "S\~_{t-1}\~"
c.LW#c.LW    "W\~^2_{t-1}\~" 
c.LW#c.LW    "W\~^2_{t-1}\~" 
c.LW#c.LW#c.LW    "W\~^3_{t-1}\~" 
c.LW#c.LW#c.LS "W\~^2_{t-1}\~ *S\~_{t-1}\~"
overLS "1/S\~_{t-1}\~"
c.LW#c.overLS "W\~_{t-1}\~ /S\~_{t-1}\~"
c.LW#c.LW#c.overLS "W\~^2_{t-1}\~ /S\~_{t-1}\~"
c.LW#c.LS "W\~_{t-1}\~ *S\~_{t-1}\~"
productivity "Productivity"
c.productivity "Productivity"
Lproductivity "Productivity\~_{t-1}\~"
c.Lproductivity "Productivity\~_{t-1}\~"
c.LW#c.productivity "W\~_{t-1}\~ * Productivity"
c.LW#c.Lproductivity "W\~_{t-1}\~ * Productivity\~_{t-1}\~"
OldorSick  "Old or Sick"
c.LW#c.OldorSick "W\~_{t-1}\~ *  Old or Sick"
c.LW#c.LW#c.OldorSick "W\~_{t-1}^2\~ *  Old or Sick"
LS "S\~_{t-1}\~"
LProt "Protest\~_{t-1}\~" 
SICK5y   "Sick" 
c.LW#c.LProt "W\~_{t-1}\~ *Protest\~_{t-1}\~" 
c.LW#c.SICK5y "W\~_{t-1}\~ *Sick" 
c.LW#c.LW#c.LProt "W\~^2_{t-1}\~ *Protest\~_{t-1}\~" 
c.LW#c.LW#c.SICK5y  "W\~^2_{t-1}\~ *Sick" 
sick  "Sick" 
c.LW#c.sick "W\~_{t-1}\~ *Sick" 
c.LW#c.LW#c.sick  "W\~^2_{t-1}\~ *Sick" 
closeToDeath   "Close to Death" 
c.LW#c.closeToDeath "W\~_{t-1}\~ *Close to Death" 
c.LW#c.LW#c.closeToDeath  "W\~^2_{t-1}\~ *Close to Death" 
eAge   "Age" 
c.LW#c.eAge "W\~_{t-1}\~ *Age" 
c.LW#c.LW#c.eAge  "W\~^2_{t-1}\~ *Age"        
logIncomingTenure "Log(Tenure)"
c.LW#c.logIncomingTenure "W\~_{t-1}\~ *Log(tenure)" 
c.LW#c.LW#c.logIncomingTenure "W\~^2_{t-1}\~ *Log(tenure)" 
L.lgdppc  "Log(GDPpc\~_{t-1}\~)"
L.lpop   "Log(Population\~_{t-1}\~)"
Llgdppc  "Log(GDPpc\~_{t-1}\~)"
c.LW#c.Llgdppc "W\~_{t-1}\~ *Log(GDPpc\~_{t-1}\~)" 
c.LW#c.LW#c.Llgdppc "W\~^2_{t-1}\~ *Log(GDPpc\~_{t-1}\~)" 

LlgdppcVDEM  "Log(GDPpc\~_{t-1}\~)"
c.LW#c.LlgdppcVDEM "W\~_{t-1}\~ *Log(GDPpc\~_{t-1}\~)" 
c.LW#c.LW#c.LlgdppcVDEM "W\~^2_{t-1}\~ *Log(GDPpc\~_{t-1}\~)" 

Llpop   "Log(Population\~_{t-1}\~)"
c.LW#c.Llpop "W\~_{t-1}\~ *Log(Pop\~_{t-1}\~)" 
c.LW#c.LW#c.Llpop "W\~^2_{t-1}\~ *Log(Pop\~_{t-1}\~)" 

LlpopVDEM   "Log(Population\~_{t-1}\~)"
c.LW#c.LlpopVDEM "W\~_{t-1}\~ *Log(Pop\~_{t-1}\~)" 
c.LW#c.LW#c.LlpopVDEM "W\~^2_{t-1}\~ *Log(Pop\~_{t-1}\~)"

c.LW#c.LlpopWB "W\~_{t-1}\~ *Log(Pop\~_{t-1}\~)" 
c.LW#c.LW#c.LlpopWB "W\~^2_{t-1}\~ *Log(Pop\~_{t-1}\~)"
L.lgdppcWB  "Log(GDPpc\~_{t-1}\~)"
L.lpopWB   "Log(Population\~_{t-1}\~)"
LlgdppcWB  "Log(GDPpc\~_{t-1}\~)"
LlpopWB   "Log(Population\~_{t-1}\~)"
c.LW#c.LlgdppcWB "W\~_{t-1}\~ *Log(GDPpc\~_{t-1}\~)" 
c.LW#c.LW#c.LlgdppcWB "W\~^2_{t-1}\~ *Log(GDPpc\~_{t-1}\~)" 
LlpopWB   "Log(Population\~_{t-1}\~)"
c.LW#c.LlpopWB "W\~_{t-1}\~ *Log(Pop\~_{t-1}\~)" 
c.LW#c.LW#c.LlpopWB "W\~^2_{t-1}\~ *Log(Pop\~_{t-1}\~)" 

growthWB  "Growth "
growthVDEM  "Growth "
c.LW#c.growthWB "W\~_{t-1}\~ *Growth" 
c.LW#c.growthVDEM "W\~_{t-1}\~ *Growth" 
c.LW#c.LW#c.growthWB "W\~^2_{t-1}\~ *Growth" 
LgrowthWB  "Growth\~_{t-1}\~ "
LgrowthVDEM  "Growth\~_{t-1}\~ "
c.LW#c.LgrowthWB "W\~_{t-1}\~ *Growth\~_{t-1}\~" 
c.LW#c.LgrowthVDEM "W\~_{t-1}\~ *Growth\~_{t-1}\~" 
c.LW#c.LW#c.LgrowthWB "W\~^2_{t-1}\~ *Growth\~_{t-1}\~" 
LGDPpc "Log(GDPpc\~_{t-1}\~)"
c.LW#c.LGDPpc "W\~_{t-1}\~ *Log(GDPpc\~_{t-1}\~)"
c.LW#c.LW#c.LGDPpc  "W\~^2_{t-1}\~ *Log(GDPpc\~_{t-1}\~)"
 LLogPOP "Log(Population\~_{t-1}\~)"
c.LW#c.LLogPOP "W\~_{t-1}\~ *Log(Pop\~_{t-1}\~)" 
 c.LW#c.LW#c.LLogPOP  "W\~^2_{t-1}\~ *Log(Pop\~_{t-1}\~)" 
growth "Growth" 
 c.LW#c.growth "W\~_{t-1}\~ *Growth" 
 c.LW#c.LW#c.growth "W\~^2_{t-1}\~ *Growth" 
ResRents    "Resource Rents"
c.LW#c.ResRents    "W\~_{t-1}\~ *Res. Rents"     
c.LW#c.LW#c.ResRents  "W\~^2_{t-1}\~ *Res. Rents"   
LResRents    "Resource Rents\~_{t-1}\~"
c.LW#c.LResRents    "W\~_{t-1}\~ *Res. Rents\~_{t-1}\~"     
c.LW#c.LW#c.LResRents  "W\~^2_{t-1}\~ *Res. Rents\~_{t-1}\~"  
aidGNI               "Aid (\%GNI)"
c.LW#c.aidGNI    "W\~_{t-1}\~ *Aid (\%GNI)"   
c.LW#c.LW#c.aidGNI   "W\~^2_{t-1}\~ *Aid (\%GNI)"      
aidYN  "Any Aid"    
c.LW#c.aidYN "W\~_{t-1}\~ *Any Aid" 
c.LW#c.LW#c.aidYN "W\~^2_{t-1}\~ *Any Aid" 


WGI_corruption "Corruption\~_{WGI}\~ "





ResPublic  "Public Residual"
ResPrivate "Private Residual"
ResFreedom "Freedom Residual"
c.ResPublic  "Public Residual"
c.ResPrivate "Private Residual"
c.ResFreedom "Freedom Residual"
 c.D1resPrivateFE "\~ \Delta\~ Res(Private)"
c.resPrivateFE#c.D1resPrivateFE  "\~ \Delta\~ Res(Private)*Res(Private)"
c.LW#c.ResPublic "W\~_{t-1}\~ *Res(Private)" 
c.LW#c.ResPrivate "W\~^2_{t-1}\~ *Private Residual" 
c.LW#c.ResFreedom "W\~^2_{t-1}\~ *Freedom Residual" 
c.LW#c.LW#c.ResPublic "W\~^2_{t-1}\~ *Public Goods Residual" 
c.LW#c.LW#c.ResPrivate "W\~^2_{t-1}\~ *Private Residual" 
c.LW#c.LW#c.ResFreedom "W\~^2_{t-1}\~ *Freedom Residual" 

c.D1resPrivateFE#c.D1resPrivateFE "\~ \Delta\~ Res(Private)\~^2\~"
c.resPrivateFE#c.D1resPrivateFE "\~ \Delta\~ Res(Private)*Res(Private)"
 c.resPrivateFE#c.resPrivateFE#c.D1resPrivateFE "\~ \Delta\~ Res(Private)*Res(Private)\~^2\~"

 c.resPrivateFE#c.resPrivateFE#c.D1resPrivateFE#c.D1resPrivateFE "\~ \Delta\~ Res(Private)\~^2\~*Res(Private)\~^2\~"
c.resPrivateFE#c.D1resPrivateFE#c.D1resPrivateFE "\~ \Delta\~Res(Private)\~^2\~*Res(Private)"
revyn   "Revolution"    
coupPT    "Coup"
LC     "Leader Change" 
hatcoup "\~\widehat{Coup}\~"
hatrev    "\~\widehat{Revolution}\~"
hatLC   "\~\widehat{Leader Change}\~"
c.LW#c.hatcoup "W\~_{t-1}\~ *\~\widehat{Coup}\~"
c.LW#c.hatrev  "W\~_{t-1}\~ *\~\widehat{Revolution}\~"       
c.LW#c.hatLC    "W\~^2_{t-1}\~ *\~\widehat{Leader Change}\~"        
c.LW#c.LW#c.hatcoup "W\~^2_{t-1}\~ *\~\widehat{Coup}\~"
c.LW#c.LW#c.hatrev "W\~^2_{t-1}\~ *\~\widehat{Revolution}\~"
c.LW#c.LW#c.hatLC "W\~^2_{t-1}\~ *\~\widehat{Leader Change}\~"


hatcoup1 "\~\widehat{Coup}\~"
hatrev1    "\~\widehat{Revolution}\~"
hatLC1   "\~\widehat{Leader Change}\~"
c.LW#c.hatcoup1 "W\~_{t-1}\~ *\~\widehat{Coup}\~"
c.LW#c.hatrev1  "W\~_{t-1}\~ *\~\widehat{Revolution}\~"       
c.LW#c.hatLC1    "W\~^2_{t-1}\~ *\~\widehat{Leader Change}\~"        
c.LW#c.LW#c.hatcoup1 "W\~^2_{t-1}\~ *\~\widehat{Coup}\~"
c.LW#c.LW#c.hatrev1 "W\~^2_{t-1}\~ *\~\widehat{Revolution}\~"
c.LW#c.LW#c.hatLC1 "W\~^2_{t-1}\~ *\~\widehat{Leader Change}\~"
revyn "Revolution"
c.LW#c.revyn "W\~_{t-1}\~ *Revolution"
c.LW#c.LW#c.revyn "W\~^2_{t-1}\~ *Revolution"
AnyCoupPT "Coup"
c.LW#c.AnyCoupPT "W\~_{t-1}\~ *Coup"
c.LW#c.LW#c.AnyCoupPT "W\~^2_{t-1}\~ *Coup"
LC   "Leader Change"
c.LW#c.LC   "W\~_{t-1}\~ *Leader Change"
c.LW#c.LW#c.LC  "W\~^2_{t-1}\~ *Leader Change"
c.LW#c.LW#c.LC "W\~^2_{t-1}*\~ Leader Change"
 
Ldemaut "Polity\~_{t-1}\~"
c.Ldemaut#c.Ldemaut "Polity\~^2_{t-1}\~"
c.Ldemaut#c.Ldemaut#c.Ldemaut "Polity\~^3_{t-1}\~"
c.Ldemaut#c.LProt "Polity\~_{t-1}\~ *Protest\~_{t-1}\~"
c.Ldemaut#c.Ldemaut#c.LProt "Polity\~^2_{t-1}\~ *Protest\~_{t-1}\~" 
c.Ldemaut#c.Ldemaut#c.Ldemaut#c.LProt "Polity\~^3_{t-1}\~ *Protest\~_{t-1}\~"
c.Ldemaut#c.sick "Polity\~_{t-1}\~ *Sick"
c.Ldemaut#c.Ldemaut#c.sick "Polity\~^2_{t-1}\~ *Sick"
c.Ldemaut#c.Ldemaut#c.Ldemaut#c.sick "Polity\~^3_{t-1}\~ *Sick"
c.Ldemaut#c.logIncomingTenure "Polity\~_{t-1}\~ *Log(Tenure)"
c.Ldemaut#c.Ldemaut#c.logIncomingTenure "Polity\~^2_{t-1}\~ *Log(Tenure)"
c.Ldemaut#c.Ldemaut#c.Ldemaut#c.logIncomingTenure "Polity\~^3_{t-1}\~ *Log(Tenure)"
c.Ldemaut#c.growthWB "Polity\~_{t-1}\~ *Growth" 
c.Ldemaut#c.growth  "Polity\~_{t-1}\~ *Growth" 
c.Ldemaut#c.hatcoup "Polity\~_{t-1}\~ *\~\widehat{Coup}\~"
c.Ldemaut#c.hatrev  "Polity\~_{t-1}\~ *\~\widehat{Revolution}\~"       
c.Ldemaut#c.hatLC    "Polity\~^2_{t-1}\~ *\~\widehat{Leader Change}\~"        
c.Ldemaut#c.Ldemaut#c.hatcoup "Polity\~^2_{t-1}\~ *\~\widehat{Coup}\~"
c.Ldemaut#c.Ldemaut#c.hatrev "Polity\~^2_{t-1}\~ *\~\widehat{Revolution}\~"
c.Ldemaut#c.Ldemaut#c.hatLC "Polity\~^2_{t-1}\~ *\~\widehat{Leader Change}\~"

c.Ldemaut#c.revyn "Polity\~_{t-1}\~ *Revolution"
c.Ldemaut#c.Ldemaut#c.revyn "Polity\~^2_{t-1}\~ *Revolution"

c.Ldemaut#c.AnyCoupPT "Polity\~_{t-1}\~ *Coup"
c.Ldemaut#c.Ldemaut#c.AnyCoupPT "Polity\~^2_{t-1}\~ *Coup"

c.Ldemaut#c.LC   "Polity\~_{t-1}\~ *Leader Change"
c.Ldemaut#c.Ldemaut#c.LC  "Polity\~^2_{t-1}\~ *Leader Change"
c.Ldemaut#c.Ldemaut#c.LC "Polity\~^2_{t-1}*\~ Leader Change"
resPublicFE "Res(Public)"
c.resPublicFE "Res(Public)"
  c.resPublicFE#c.resPublicFE "Res(Public)\~^2\~"
  c.LW#c.resPublicFE "W\~_{t-1}\~ *Res(Public)"
  c.LW#c.LW#c.resPublicFE "W\~^2_{t-1}\~ *Res(Public)"
  c.LW#c.resPublicFE#c.resPublicFE  "W\~_{t-1}\~ *Res(Public)\~^2\~"   
   c.LW#c.LW#c.resPublicFE#c.resPublicFE  "W\~^2_{t-1}\~ *Res(Public)\~^2\~"
   
c.D1resPublicFE "\~\Delta\~Res(Public)"
D1resPublicFE "\~\Delta\~Res(Public)"
c.D1resPublicFE#c.D1resPublicFE "\~\Delta\~Res(Public)\~^2\~"
c.resPublicFE#c.D1resPublicFE "Res(Public)\~\Delta\~Res(Public)"
c.resPublicFE#c.resPublicFE#c.D1resPublicFE "Res(Public)\~^2\Delta\~Res(Public)"
c.resPublicFE#c.D1resPublicFE#c.D1resPublicFE "Res(Public)\~\Delta\~Res(Public)\~^2\~"
c.resPublicFE#c.resPublicFE#c.D1resPublicFE#c.D1resPublicFE "Res(Public)\~^2\Delta\~Res(Public)\~^2\~"

c.D1resAssemblyFE "\~\Delta\~Res(Assembly)"
D1resAssemblyFE "\~\Delta\~Res(Assembly)"
c.D1resAssemblyFE#c.D1resAssemblyFE "\~\Delta\~Res(Assembly)\~^2\~"
c.resAssemblyFE#c.D1resAssemblyFE "Res(Assembly)\~\Delta\~Res(Assembly)"
c.resAssemblyFE#c.resAssemblyFE#c.D1resAssemblyFE "Res(Assembly)\~^2\Delta\~Res(Assembly)"
c.resAssemblyFE#c.D1resAssemblyFE#c.D1resAssemblyFE "Res(Assembly)\~\Delta\~Res(Assembly)\~^2\~"
c.resAssemblyFE#c.resAssemblyFE#c.D1resAssemblyFE#c.D1resAssemblyFE "Res(Assembly)\~^2\Delta\~Res(Assembly)\~^2\~"
   
   
  
   
   
   
  resPrivateFE "Res(Private)"
  c.resPrivateFE#c.resPrivateFE "Res(Private)\~^2\~"
  c.LW#c.resPrivateFE "W\~_{t-1}\~ *Res(Private)"
  c.LW#c.LW#c.resPrivateFE "W\~^2_{t-1}\~ *Res(Private)"
  c.LW#c.LW#c.resPrivateFE#c.resPrivateFE  "W\~^2_{t-1}\~ *Res(Private)\~^2\~"
  
  resAssemblyFE "Res(Assembly)"
  c.resAssemblyFE "Res(Assembly)"
  c.resAssemblyFE#c.resAssemblyFE "Res(Assembly)\~^2\~"
  c.LW#c.resAssemblyFE "W\~_{t-1}\~ *Res(Assembly)"
  c.LW#c.LW#c.resAssemblyFE "W\~^2_{t-1}\~ *Res(Assembly)"
  c.LW#c.resAssemblyFE#c.resAssemblyFE  "W\~_{t-1}\~ *Res(Assembly)\~^2\~"
  c.LW#c.LW#c.resAssemblyFE#c.resAssemblyFE  "W\~^2_{t-1}\~ *Res(Assembly)\~^2\~"
  resCWFE "Res(Coal.Welfare)"
    c.resCWFE "Res(Coal.Welfare)"
  c.resCWFE#c.resCWFE "Res(Coal.Welfare)\~^2\~"
  c.LW#c.resCWFE "W\~_{t-1}\~ *Res(Coal.Welfare)"
  c.LW#c.resCWFE#c.resCWFE  "W\~_{t-1}\~ *Res(Coal.Welfare)\~^2\~"  
  c.LW#c.LW#c.resCWFE#c.resCWFE  "W\~^2_{t-1}\~ *Res(Coal.Welfare)\~^2\~"  
   c.LW#c.LW#c.resCWFE  "W\~^2_{t-1}\~ *Res(Coal.Welfare)" 

  D1resPrivateFE "\~\Delta\~Res(Private)"
  c.D1resPrivateFE "\~\Delta\~Res(Private)"
   c.LW#c.D1resPrivateFE "W\~_{t-1}\~ *\~\Delta\~Res(Private)"
   c.LW#c.LW#c.D1resPrivateFE "W\~^2_{t-1}\~ *\~\Delta\~Res(Private)"
   
   c.resPrivateFE#c.D1resPrivateFE "Res(Private)*\~\Delta\~Res(Private)"
   c.D1resPrivateFE#c.D1resPrivateFE "\~\Delta\~Res(Private)\~^2\~"
   c.LW#c.resPrivateFE#c.D1resPrivateFE "W\~_{t-1}\~ *Res(Private)*\~\Delta\~Res(Private)"
   c.LW#c.LW#c.resPrivateFE#c.D1resPrivateFE "W\~^2_{t-1}\~ *Res(Private)*\~\Delta\~Res(Private)"
resPublicLight "Res(Public)"
  c.resPublicLight#c.resPublicLight "Res(Public)\~^2\~"
  c.LW#c.resPublicLight "W\~_{t-1}\~ *Res(Public)"
  c.LW#c.resPublicLight#c.resPublicLight  "W\~_{t-1}\~ *Res(Public)\~^2\~"   
  
  resPrivateLight "Res(Private)"
  c.resPrivateLight#c.resPrivateLight "Res(Private)\~^2\~"
  c.LW#c.resPrivateLight "W\~_{t-1}\~ *Res(Private)"
  c.LW#c.resPrivateLight#c.resPrivateLight  "W\~_{t-1}\~ *Res(Private)\~^2\~"
  
  resAssemblyLight "Res(Assembly)"
  c.resAssemblyLight#c.resAssemblyLight "Res(Assembly)\~^2\~"
  c.LW#c.resAssemblyLight "W\~_{t-1}\~ *Res(Assembly)"
  c.LW#c.resAssemblyLight#c.resAssemblyLight  "W\~_{t-1}\~ *Res(Assembly)\~^2\~"  
  
  
 resPublicOOS "Res(Public)"
  c.resPublicOOS#c.resPublicOOS "Res(Public)\~^2\~"
  c.LW#c.resPublicOOS "W\~_{t-1}\~ *Res(Public)"
  c.LW#c.resPublicOOS#c.resPublicOOS  "W\~_{t-1}\~ *Res(Public)\~^2\~"   
  
  resPrivateOOS "Res(Private)"
  c.resPrivateOOS#c.resPrivateOOS "Res(Private)\~^2\~"
  c.LW#c.resPrivateOOS "W\~_{t-1}\~ *Res(Private)"
  c.LW#c.resPrivateOOS#c.resPrivateOOS  "W\~_{t-1}\~ *Res(Private)\~^2\~"
  
  resAssemblyOOS "Res(Assembly)"
  c.resAssemblyOOS#c.resAssemblyOOS "Res(Assembly)\~^2\~"
  c.LW#c.resAssemblyOOS "W\~_{t-1}\~ *Res(Assembly)"
  c.LW#c.resAssemblyOOS#c.resAssemblyOOS  "W\~_{t-1}\~ *Res(Assembly)\~^2\~"
 rev01 "Revolution"
 coup01 "Coup"
 hatLCirreg01   "\~\widehat{iregLC}\~"
  hatLCirreg "\~\widehat{IrregLC}\~"
 LCirreg01 "Irregular LC"
  hatrev01 "\~\widehat{Rev}\~"
c.LW#c.hatrev01 "W\~_{t-1}* \widehat{Rev}\~"
c.LW#c.LW#c.hatrev01 "W\~_{t-1}^2* \widehat{Rev}\~"
hatcoup01 "\~\widehat{Coup}\~"
c.LW#c.hatcoup01 "W\~_{t-1}* \widehat{Coup}\~" 
c.LW#c.LW#c.hatcoup01 "W\~_{t-1}^2* \widehat{Coup}\~"
hatLC01 "\~\widehat{LC}\~" 
c.LW#c.hatLC01 "W\~_{t-1}* \widehat{LC}\~" 
c.LW#c.LW#c.hatLC01 "W\~_{t-1}^2* \widehat{LC}\~"
c.hatrev01#c.hatcoup01 "\~\widehat{Rev}* \widehat{Coup}\~"
c.LW#c.hatrev01#c.hatcoup01 "W\~_{t-1}* \widehat{Rev}* \widehat{Coup}\~" 
c.LW#c.LW#c.hatrev01#c.hatcoup01 "W\~_{t-1}^2* \widehat{Rev}* \widehat{Coup}\~" 
 phatrev01 "\~\widehat{Rev}\~"
c.LW#c.phatrev01 "W\~_{t-1}* \widehat{Rev}\~"
c.LW#c.LW#c.phatrev01 "W\~_{t-1}^2* \widehat{Rev}\~"
phatcoup01 "\~\widehat{Coup}\~"
c.LW#c.phatcoup01 "W\~_{t-1}* \widehat{Coup}\~" 
c.LW#c.LW#c.phatcoup01 "W\~_{t-1}^2* \widehat{Coup}\~"
phatLC01 "\~\widehat{LC}\~" 
c.LW#c.phatLC01 "W\~_{t-1}* \widehat{LC}\~" 
c.LW#c.LW#c.phatLC01 "W\~_{t-1}^2* \widehat{LC}\~"
c.phatrev01#c.phatcoup01 "\~\widehat{Rev}* \widehat{Coup}\~"
c.LW#c.phatrev01#c.phatcoup01 "W\~_{t-1}* \widehat{Rev}* \widehat{Coup}\~" 
c.LW#c.LW#c.phatrev01#c.phatcoup01 "W\~_{t-1}^2* \widehat{Rev}* \widehat{Coup}\~" 
L.PTS_S "PTS\~_{t-1}\~"
L.PHYSINT "Physical Integrity\~_{t-1}\~" 
L.Torture "Torture\~_{t-1}\~" 
L.politicalkilling "Political Killing\~_{t-1}\~" 
"; 


#delimit;
/***** Add some programs ******/
/******** USEFUL PROGRAMS **********/
/* write a program to create figures in multiple formats*/ 
capture program drop outgraph; program define outgraph;
graph export "${storeresult}/$name.pdf",replace; 
graph export "${storeresult}/altformat/$name.eps",replace;
graph export "${storeresult}/altformat/$name.png",replace; 
graph export "${storeresult}/altformat/$name.tif",replace; end; 

/* Program to make leads and difference*/ 
capture program drop FandD; program define FandD; 
args x; foreach i of numlist 1/6 {; regen F`i'`x' =F`i'.`x',replace; regen D`i'`x' =F`i'.`x'-`x',replace;}; end;
 
/* Run file to define programs needed for Out-of-Sample test */ 

global domain " year>1900 ";
/* Mini Program to look at OOS fit for continuous dependent variables: specify dependent variable as global dep and the independent variables as global model. The OOS predictions are reported as res${dep}OOS and scalar r2oos provides a simple measure of goodness of fit by regressing the OOS predictions and the dependent variables and reporting R-squared. */
capture program drop oos; program define oos; 
regen hatOOS=.,replace; regen res${dep}OOS=.,replace; 
foreach g of numlist 1/6 {;
/***** Step 1: predict public/private residuals ******/
capture drop hat; capture drop res; 
regr $dep $model if group~=`g' & inlist(group,1,2,3,4,5,6) & $domain; 
predict hat; predict res, res;
regen hat${dep}OOS =hat if group ==`g',replace;
regen res${dep}OOS =res if group ==`g',replace;
}; regress $dep hat${dep}OOS, ;  scalar r2oos=e(r2); scalar Noos=e(N);
capture drop hat; capture drop res; end;
/* Program to run OLS on different groups to create out of sample predictions */
capture program drop oosREG; program define oosREG; 
regen hatOOS=.,replace; regen res${dep}OOS=.,replace; 
foreach g of numlist 1/6 {;
/***** Step 1: predict public/private residuals ******/
capture drop hat; capture drop res; 
regr $dep $model if group~=`g'; 
predict hat; predict res, res;
regen hatOOS =hat if group ==`g',replace;
regen res${dep}OOS =res if group ==`g',replace;
}; regress $dep hatOOS, nocons;  scalar Noos=e(N); scalar r2oos=e(r2);
end;

/* Now create the same program to run with nation fixed effects */
#delimit;
capture program drop oosFE; program define oosFE; 
regen hatOOS=.,replace; regen res${dep}OOS=.,replace; 
foreach g of numlist 1/6 {;
/***** Step 1: predict public/private residuals ******/
capture drop hat; capture drop ufe; capture drop UFE; 
*reghdfe $dep $model if group~=`g' & inlist(group,1,2,3,4,5,6) & $domain, a(ccode ) res(residual); 
xtreg $dep $model if group~=`g' & inlist(group,1,2,3,4,5,6) & $domain, fe i(ccode ); 
predict hat, xb ; predict ufe, u ; /* ufe is country fixed effect -- bbut only for the sample in regression */ 
by ccode: egen UFE = mean(ufe); 
regen hat${dep}OOS =hat +UFE  if group ==`g',replace;
regen res${dep}OOS =$dep -hat -UFE if group ==`g',replace;
}; regress $dep hat${dep}OOS  if $domain ;  scalar r2oos=e(r2); scalar Noos=e(N);

capture drop hat; capture drop res; capture drop residual; end;
 
 

/* Now create the same program to run with logit model  */
/*********** Generate out of sample stuff for Discrete events ************/ 
/* The program oosEvent carries out OOS predictions using similar procedures to those above. The basic model is logit $dep $model. The OOS is as follows: exlude group 1 and run logit. Then use estimates to predict on the observations in excluded group 1. The repeat for the other groups, sequentially excluding each. Having generated OOS predictions ${dep}hatOOS, the program assesses the fit by calculating ROC between the dependent variable and OOS predicted values. This ROC statisitic is returned as scalar roc. */
 capture program drop oosEvent; program define oosEvent; 
 /* The global $oosEventCond refers to any additional  restriction */
 quietly regen ${dep}hatOOS =.,replace; 
foreach g of numlist 1/6 {;
quietly di "The interation is `g' ";
/***** Step 2: predict revolution or other event OOS *****/
 capture logit ${dep} $model  if group~=`g' & inlist(group,1,2,3,4,5,6) $oosEventCond ;
if _rc==0 {;  capture drop hat; quietly  predict hat,xb ;  regen ${dep}hatOOS=hat if group==`g' $oosEventCond,replace; capture drop hat;};
else if _rc~=0 {; display _rc;};
}; 
capture roctab ${dep} ${dep}hatOOS;
if _rc==0 {;/*quietly lroc, nograph;*/  display "Dep is $dep . Model is $num .  LROC is " r(area) " based on " r(N) " observations"; scalar Obs=r(N); scalar roc=r(area);
capture frame post $temp ( "${dep}" ) ($num) (Obs) (roc); }; 
else if _rc~=0 {; display _rc; display "group is " `g';};
end; 
#delimit;
/* Program to generate extra data for output tables: returns Nnum as number of unique nations in the analysis and yy as the range of years in the analysis. */
capture program drop extraout;
program define extraout; sum year if e(sample)==1; local ymin =r(min); local ymax= r(max);local years `ymin'-`ymax';estadd local yy `years'; unique ccode if e(sample)==1;estadd scalar Nnum r(unique);end;

/*****color setting for graphs *****/ 
global cs "plot1opts(lcolor(black) lpattern(solid) mcolor(black) msymbol(Oh) lwidth(thick)) plot2opts(lcolor(red)  lpattern(dash) mcolor(red) msymbol(Dh) lwidth(thick))  ci2opts(lpattern(dash) lcolor(red)) ";
global cs1 "plot1opts(lcolor(black) lpattern(solid) mcolor(black) msymbol(Oh) lwidth(thick))  ";
global cs3 "plot1opts(lcolor(red)  lpattern(dash) mcolor(red) msymbol(Dh) lwidth(thick)) plot2opts(lcolor(black) lpattern(solid) mcolor(black) msymbol(Oh) lwidth(thick))  plot3opts(lcolor(blue)  lpattern(dash_dot) mcolor(blue) msymbol(Sh) lwidth(thick)) ci1opts(lpattern(dash) lcolor(red)) ci2opts(lpattern(dash) lcolor(black)) ci3opts(lpattern(dash) lcolor(blue))";
global cs1BW "plot1opts(  lpattern(solid)   msymbol(Oh) lwidth(thick))  scheme(s2mono)  ";
global csBW "plot1opts(  lpattern(solid)   msymbol(Oh) lwidth(thick)) plot2opts(   lpattern(dash)   msymbol(Dh) lwidth(thick))  scheme(s2mono)  ";
global cs3BW "plot1opts(  lpattern(dash)  msymbol(Dh) lwidth(thick)) plot2opts(  lpattern(solid)   msymbol(Oh) lwidth(thick))  plot3opts(   lpattern(dash_dot)   msymbol(Sh) lwidth(thick)) scheme(s2mono)";
#delimit;
global cs4BW "plot1opts(  lpattern(dash)  msymbol(Dh) lwidth(thick)) plot2opts(  lpattern(solid)   msymbol(Oh) lwidth(thick))  plot3opts(   lpattern(dash_dot)   msymbol(Sh) lwidth(thick)) plot4opts(   lpattern(shortdash_dot)   msymbol(Th) lwidth(thick)) scheme(s2mono)";
global cs4 "plot1opts(lcolor(red)  lpattern(dash) mcolor(red) msymbol(Dh) lwidth(thick)) plot2opts(lcolor(black) lpattern(solid) mcolor(black) msymbol(Oh) lwidth(thick))  plot3opts(lcolor(blue)  lpattern(dash_dot) mcolor(blue) msymbol(Sh) lwidth(thick)) ci1opts(lpattern(dash) lcolor(red)) ci2opts(lpattern(dash) lcolor(black)) ci3opts(lpattern(dash) lcolor(blue))   plot4opts(   lpattern(shortdash_dot) lcolor(green) mcolor(green)  msymbol(Th) lwidth(thick)) ci4opts(lpattern(shortdash_dot) lcolor(green))";
global style1 "lcolor(black) lpattern(solid) mcolor(black) msymbol(Oh) lwidth(thick)";
global style2 "lcolor(red) lpattern(dash) mcolor(red) msymbol(Dh) lwidth(thick)";
global style3 "lcolor(blue) lpattern(dash_dot) mcolor(blue) msymbol(S) lwidth(thick)";
global style4 "lcolor(green) lpattern(shortdash_dot) mcolor(green) msymbol(Th) lwidth(thick)";
global style5 "lcolor(orange) lpattern(solid) mcolor(black) msymbol(Oh) lwidth(thick)";
global style6 "lcolor(purple) lpattern(dash) mcolor(red) msymbol(Dh) lwidth(thick)";
global style7 "lcolor(brown) lpattern(longdash_dot) mcolor(brown) msymbol(Dh) lwidth(thick)";
global style1BW "lcolor(black) lpattern(solid) mcolor(black) msymbol(Oh) lwidth(thick)";
global style2BW "lcolor(gs4) lpattern(dash) mcolor(gs4) msymbol(Dh) lwidth(thick)";
global style3BW "lcolor(gs8) lpattern(dash_dot) mcolor(gs8) msymbol(S) lwidth(thick)";
global style4BW "lcolor(gs10) lpattern(shortdash_dot) mcolor(green) msymbol(Th) lwidth(thick)";
global style5BW "lcolor(gs4) lpattern(dash) mcolor(gs10) msymbol(Dh) lwidth(thick)";
global style6BW "lcolor(gs8) lpattern(dash_dot) mcolor(gs2) msymbol(S) lwidth(thick)";
global style7BW "lcolor(gs10) lpattern(longdash_dot) mcolor(gs2) msymbol(S) lwidth(thick)";
